Shader "TideShader/1_顶点动画旋转"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _Speed("旋转速度",float) = 0
    }
    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            sampler2D _MainTex;
            float _Speed;

            struct appdata
            {
                float4 vertex:POSITION;
                float2 uv:TEXCOORD0;
            };

            struct v2f
            {
                float4 vertex:SV_POSITION;
                float2 uv:TEXCOORD0;
            };

            float3 RotateY(float3 pos, float angle)
            {
                float3 o;
                o.x = pos.x * cos(angle) + pos.z * sin(angle);
                o.y = pos.y;
                o.z = -pos.x * sin(angle) + pos.z * cos(angle);
                return o;
            }


            v2f vert(appdata i)
            {
                v2f o;

                float angle = _Time.y * _Speed;
                i.vertex.xyz = RotateY(i.vertex.xyz, angle);
                o.vertex = UnityObjectToClipPos(i.vertex);
                o.uv = i.uv;

                return o;
            }

            fixed4 frag(v2f i):SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                return col;
            }
            ENDCG
        }
    }
}